﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_Ngayle : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            danhsach(0);
        }
    }
    protected void danhsach(int index)
    {
        clsTableAction clsTable = new clsTableAction("NgayLe");
        clsTable.exportDataToGridview("*", "", ref GridView1, 5, index);
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        danhsach(e.NewPageIndex);
    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.EditIndex = e.NewEditIndex;
        danhsach(GridView1.PageIndex);
    }
    protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        GridView1.EditIndex = -1;
        danhsach(GridView1.PageIndex);
    }
    protected void ThemNgayLe_Click(object sender, EventArgs e)
    {
        //them thong bao
        clsTableAction clsTable = new clsTableAction("NgayLe");
        string str = string.Format("select * from NgayLe where NgayLe='" + TextBox1.Text + "'");
        int kq = 0;
        //string sql = "select max(id_p) from page";
        //string id = (clsTable.runReturnSQL(sql) + 1).ToString();
        clsTable.runSQL(str, out kq);
        if (kq > 0)
        {
            Label3.Text = "Ngày  da ton tai";
            TextBox1.Text = "";
            return;
        }
        else
        {
            string sql = string.Format("insert into NgayLe values('{0}','{1}');", TextBox1.Text, TextBox2.Text);

            if (clsTable.runSQL(sql))
            {
                //    GridView2.EditIndex = -1;
                //    danhsach_tb(0);
                Label3.Text = "Tin bạn đăng thành công";
                TextBox1.Text = "";
                TextBox2.Text = "";


            }
            else { Label3.Text = "Tin bạn đăng khong thành công"; }
        }
    }
    //protected void sinhnhat()
    //{
    //    clsTableAction clsTable = new clsTableAction("ThongTin_KH");
    //    string str = string.Format("select * from ThongTin_KH where NgaySinh='" + DateTime.Now + "'");
    //    bool kq = false;
    //    kq = clsTable.ktrunSQL(str);
    //    if (kq == false)
    //    {
    //        Label4.Text = "hnay sinh nhat ban";
    //        TextBox1.Text = "";
    //        return;
    //    }
    //}
   
}